package cn.hfuu.interceptor;

import cn.hfuu.domain.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import org.aopalliance.intercept.Invocation;

import java.util.Map;

public class PrivilegeInterceptor extends MethodFilterInterceptor {
    protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
        Map<String,Object> session = ActionContext.getContext().getSession();
        User user = (User) session.get("user");
        if(user != null) {
            return actionInvocation.invoke();
        }
        else {
          return "toLogin";
        }
    }
}
